package com.taoyun.web.handler;

import com.taoyun.utils.Response;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * 处理抛出的异常，返回json格式的消息体
 *
 * @author FengJingdong
 */
@RestControllerAdvice
public class CommentExceptionHandler {

    /**
     *  处理抛出的 Exception
     * @param exception 抛出的异常
     * @return 通用 Json Response对象
     */
    @ExceptionHandler(Exception.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public Response handle500(Exception exception) {
        return new Response("500",exception.getMessage(),null);
    }
}
